package com.xinqi.modules.chat.chat.friend.factory;

import com.xinqi.common.base.error.CommonErrors;
import com.xinqi.common.base.response.R;
import com.xinqi.modules.chat.chat.friend.client.ChatFriendClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 好友列表降级处理
 *
 * @author: system
 * @date: 2023/01/12
 */
@Slf4j
@Component
public class ChatFriendFallbackFactory implements FallbackFactory<ChatFriendClient> {

    @Override
    public ChatFriendClient create(Throwable throwable) {
        log.error("日志服务调用失败:{}", throwable.getMessage());
        return new ChatFriendClient() {

            @Override
            public R<Boolean> initFriend(Long userId) {
                return R.error(CommonErrors.INTERNAL_SERVER_ERROR.getCode(), null);
            }

        };
    }
}
